# -*- coding: utf-8 -*-
'''
Created on 26-11-2012

@author: LONG HOANG GIANG
'''

import sys
import os
import datetime
from Model.storymodelv3 import StoryModel

def join(output, s1, s2):
    db = StoryModel(output)
    db.open(True)
    db1 = StoryModel(s1)
    db1.open()
    db2 = StoryModel(s2)
    db2.open()
    
    stories = db1.get_all_stories()
    for story in stories:
        db.add_story(story[2], story[3], story[1])
    
    stories = db2.get_all_stories()
    for story in stories:
        db.add_story(story[2], story[3], story[1])
    
    db2.close()
    db1.close()
    
    for s in db.get_all_stories():
        print s[2]
    
    db.close()

if __name__ == '__main__':
    
    
    join('j:/longhoanggiang/database/truyen18p2013haynhat', 'j:/longhoanggiang/database/sexhaynhat1', 'j:/longhoanggiang/database/tnl')
    
    print '> Finished at {0}'.format(datetime.datetime.now())
    os._exit(1)